package com.yunti.springboot.controller;

import com.yunti.springboot.annotation.Log;
import com.yunti.springboot.annotation.Permission;
import com.yunti.springboot.service.IRoleService;
import com.yunti.springboot.vo.Result;
import com.yunti.springboot.vo.req.RoleAddReq;
import com.yunti.springboot.vo.req.RoleReq;
import com.yunti.springboot.service.IRoleService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 用户角色关联表 前端控制器
 * </p>
 *
 * @author kmustleng
 * @since 2022-12-09
 */
@RestController
@RequestMapping("/role")
public class RoleController {
    @Resource
    IRoleService service;

    @PostMapping("/getRuleList")
    public Result getRuleList(){
        return Result.success(service.getRuleList());
    }

    @PostMapping("/getOwnRuleList")
    public Result getOwnRuleList(){
        return Result.success(service.getOwnRuleList());
    }

    @PostMapping("/getRulePageList")
    public Result getRulePageList(@RequestBody RoleReq req){
        return service.getRulePageList(req);
    }

    @Log
    @Permission({"superAdmin","roleManage"})
    @PostMapping("/addRole")
    public Result addRole(@RequestBody RoleAddReq req){
        return service.addRole(req);
    }

    @Log
    @Permission({"superAdmin","roleManage"})
    @PostMapping("/editRole")
    public Result editRole(@RequestBody RoleReq req){
        return service.editRole(req);
    }

    @Log
    @Permission({"superAdmin","roleManage"})
    @PostMapping("/delRole")
    public Result delRole(@RequestBody RoleReq req){
        return service.delRole(req);
    }
}
